package com.onpositive.properties.editor.model;

import com.onpositive.data.units.UnitKind;

public class ParserData {
	
	public ParserData(String id, int count, UnitKind unitKind) {
		super();
		this.id = id;
		this.count = count;
		this.unitKind = unitKind;
	}

	String id;
	
	int count;
	
	UnitKind unitKind;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public UnitKind getUnitKind() {
		return unitKind;
	}

	public void setUnitKind(UnitKind unitKind) {
		this.unitKind = unitKind;
	}
	
	@Override
	public String toString() {
		
		StringBuilder bld = new StringBuilder(getLabel());
		bld.append(": ");
		bld.append(""+count);
		
		String result = bld.toString();
		return result;
	}

	private String getLabel() {
		StringBuilder bld = new StringBuilder();
		bld.append( id != null ? id : "null");
		bld.append( unitKind != null ? " "+unitKind.name() : "");
		String label = bld.toString();
		return label;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + count;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((unitKind == null) ? 0 : unitKind.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ParserData other = (ParserData) obj;
		if (count != other.count)
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (unitKind != other.unitKind)
			return false;
		return true;
	}
}
